package bTree.LeetCode;

import java.util.Arrays;

public class 划分技能点相等的团队 {
    public long dividePlayers(int[] skill) {
        Arrays.sort(skill);
        int length = skill.length;
        long sum=0;
        int point=skill[0]+skill[length-1];
        int left=0,right=length-1;
        while (left<right){
            if (skill[left]+skill[right]==point){
                sum+= (long) skill[left] *skill[right];
                left++;
                right--;
            }else {
                return -1;
            }
        }
        return sum;
    }
}
